import http from "@/http/request";

export const getUserInfo: any = async () => {
    return http.request({
        url: '/user/profile',
        method: 'get'
    })
}

export const uploadAvatar: any = async (data: any) => {
    return http.request({
        url: '/user/avatar',
        data: data,
        method: 'post',
    })
}

export const getUserInformation: any = () => {
    return http.request({
        url: '/user/information',
        method: 'get'
    })
}

export const postUserInformation: any = (data: any) => {
    return http.request({
        url: '/user/information',
        data: {information: data},
        method: 'post'
    })
}

export const clearUserInformation: any = () => {
    return http.request({
        url: '/user/information',
        data: {information: ""},
        method: 'post'
    })
}

export const modifyUserBase: any = (data: any) => {
    return http.request({
        url: '/user/profile',
        data: data,
        method: 'put'
    })
}

//  用户注册
export const userRegister: any = (data: any) => {
    return http.request({
        url: '/auth/register',
        data: data,
        method: 'post'
    })
}

//  用户登录，loginType: password | verificationCode
export const userLogin: any = (data: any) => {
    return http.request({
        url: '/auth/login',
        data: data,
        method: 'post'
    })
}

// 修改密码
export const changePassword: any = (data: any) => {
    return http.request({
        url: '/auth/change-password',
        data: data,
        method: 'post'
    })
}

// 注册验证码
export const registerVerificationCode: any = (data: any) => {
    return http.request({
        url: '/verification-code/register',
        data: data,
        method: 'post'
    })
}

// 登录验证码
export const loginVerificationCode: any = (data: any) => {
    return http.request({
        url: '/verification-code/login',
        data: data,
        method: 'post'
    })
}

// 发送修改密码验证码
export const changePasswordVerificationCode: any = (data: any) => {
    return http.request({
        url: '/verification-code/change-password',
        data: data,
        method: 'post'
    })
}